package com.bite.lesson1;

public class Demo_03 {
    public static void main(String[] args) {
        //使用匿名内部类 继承 Thread
        Thread thread04 = new Thread() {
            @Override
            public void run() {
                System.out.println("使用匿名内部类 继承 Thread......");
            }
        };

        //使用匿名内部类 继承 Runnable
        Thread thread05 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("使用匿名内部类 继承 Runnable......");
            }
        });

        //使用匿名内部类 lambda 表达式继承 Runnable 接口
        Thread thread06 = new Thread( () -> System.out.println("使用匿名内部类 lambda 表达式继承 Runnable 接口......") );

        MyThread05 myThread05 = new MyThread05();
        MyThread06 myThread06 = new MyThread06();

        Thread thread07 = new Thread(myThread06);

        //开启线程

        myThread05.start();
        thread07.start();
        thread04.start();
        thread05.start();
        thread06.start();

    }

}

//继承 Thread
class MyThread05 extends Thread {
    @Override
    public void run() {
        System.out.println("继承 Thread 的线程......");
    }
}

//继承接口 Runnable
class MyThread06 implements Runnable {
    @Override
    public void run() {
        System.out.println("继承接口 Runnable 的线程......");
    }
}
